// created by noellynch
// Jun 4, 2009

package com.sceneworker.editors.glslshadereditor.uniformreps;

import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.JTextField;

import com.jme.scene.state.GLSLShaderObjectsState;
import com.jme.util.shader.ShaderVariable;
import com.jme.util.shader.uniformtypes.ShaderVariableFloat;
import com.myjavautils.swing.MigLayoutUtils;
import com.sceneworker.editors.glslshadereditor.UniformRepresentations.IUniformRepresentation;

public class Float1Rep extends BaseUniformRep implements IUniformRepresentation {

	public static final String NAME = "Float";

	public	Float1Rep() {
		super();
	}
	
	public void createUniform(GLSLShaderObjectsState cl_state, String str_name) {
		cl_state.setUniform(str_name, 0.0f);
	}

	public Class<?> getUniformClassRep() {
		return ShaderVariableFloat.class;
	}

	@Override
	public String getNameRep() {
		return NAME;
	}

	public ArrayList<JTextField> getUIRep(ShaderVariable cl_v, JPanel cl_parentPanel) {
		JTextField	lcl_v = MigLayoutUtils.numberText(cl_parentPanel, "Value", ((ShaderVariableFloat)cl_v).value1, true);
		
		return uiFields(lcl_v);
	}

	public String getValueRep(ShaderVariable cl_v) {
		ShaderVariableFloat		lcl_v = (ShaderVariableFloat)cl_v;
		
		return out(lcl_v.value1);
	}

	public	void	updateFromUI(GLSLShaderObjectsState cl_shaderState, ArrayList<JTextField> cla_values, ShaderVariable cl_v) {
		cl_shaderState.setUniform(cl_v.name, Float.parseFloat(cla_values.get(0).getText()));
	}
}
